﻿@model PlanificadorDeEventos.Models.Evento

@{
    ViewBag.Title = "Detalle";
}

<script type="text/javascript" language="javascript">
    $("a[rel='pop-up']").click(function () {
        var caracteristicas = "height=380,width=400,scrollTo,resizable=1,scrollbars=1,location=0";
        nueva = window.open(this.href, 'Popup', caracteristicas);
        return false;
    });
</script>



<h2>Detalles</h2>

<fieldset>
    <legend>Evento</legend>


<table class="bordered">
        <tr>
            <th>
                 @Html.DisplayNameFor(model => model.Nombre)
            </th>
            <th>
                 @Html.DisplayNameFor(model => model.Description)
            </th>
            <th style="padding-right:15px">
                @Html.DisplayNameFor(model => model.Date)
            </th>
            <th>
                 @Html.DisplayNameFor(model => model.EndRegistrationDate)
            </th>
            <th style="padding-left:10px">
                 @Html.DisplayNameFor(model => model.CupoMaximo)
            </th>


        </tr>
            <tr>
                <td>
                    <div class="display-field">
                        @Html.DisplayFor(model => model.Nombre)
                    </div>
                </td>
                <td>
                    <div class="display-field">
                        @Html.DisplayFor(model => model.Description)
                    </div>
                </td>
                <td>
                     <div class="display-field">
                        @Html.DisplayFor(model => model.Date)
                    </div>
                </td>
                <td>
                   <div class="display-field">
                       @{if (Model.EndRegistrationDate < DateTime.Now)
                         {
                             ViewBag.showreg = false;
                             <font color="red">@Html.DisplayFor(model => model.EndRegistrationDate) </font>}
                       else{
                         @Html.DisplayFor(model => model.EndRegistrationDate)   
                           ViewBag.showreg = true;
                           }
                       }
                    </div>
                </td>
                 <td style="padding-left:10px">
                     <div class="display-field">
                        @Html.DisplayFor(model => model.CupoMaximo)
                    </div>
                </td>
                
            </tr>
</table>
@{if (Model.EndRegistrationDate < DateTime.Now)
  {
      <p style="padding-top:1px">
        <font color=red size=2>La fecha de inscripcion al evento expiro</font>
      </p>
  }
}
</fieldset>


<h2>Organizadores</h2>
 <table class="bordered">
        <tr>
            <th style="padding-right:15px">
                @Html.DisplayName("Nombre")
            </th>
            <th>
                @Html.DisplayName("Email")
            </th>

        </tr>

    @foreach (var item in ViewBag.Organizadores)
    {
            <tr>
                <td>
                    @item.Guest.Nombre
                </td>
                <td>
                    @item.Guest.Email
                </td>
            </tr>
    }

</table>


<h2>Participantes</h2>

 <table class="bordered">
        <tr>
            <th style="padding-right:15px">
                @Html.DisplayName("Nombre")
            </th>
            <th>
                 @Html.DisplayName("Email")
            </th>
            <th>
                 @Html.DisplayName("Estado")
            </th>
            <th>
                 @Html.DisplayName("Acción")
            </th>
             
            
        </tr>

    @foreach (var item in ViewBag.Participantes)
    {

        if (item.confirmado)
        {
            <tr>
                <td>
                    @item.Guest.Nombre
                </td>
                <td>
                    @item.Guest.Email
                </td>
                <td>
                    Confirmado
                </td>
                @{if (ViewBag.showconfirm || String.Compare(item.Guest.Nombre, User.Identity.Name, true) == 0)//es organizador del evento o es un usuario registrado al evento
                  {
                    <td>
                        @Html.ActionLink("Eliminar", "Eliminar", new { idEvento = ViewBag.id, idGuest = item.GuestID })
                    </td>
                  }
                  else 
                  {
                    <td>
                    </td>
                  }
                 }
                
            </tr>
        }
        else
        { 
            <tr>
                <td>
                   <font color="red">@item.Guest.Nombre </font> 
                </td>
                <td>
                   <font color="red">@item.Guest.Email</font>
                </td>
                <td>
                   <font color="red">Falta confirmar</font>
                </td>
            @{
              if (ViewBag.showconfirm)
              {
                    <td>
                     @Html.ActionLink("Confirmar", "Confirmar", new { idEvento = ViewBag.id, idGuest = item.GuestID })
                     @Html.ActionLink("Eliminar", "Eliminar", new { idEvento = ViewBag.id, idGuest = item.GuestID })
                    </td>
              }
              else
              {
                if (String.Compare(item.Guest.Nombre, User.Identity.Name, true) == 0 || ViewBag.showconfirm)
                {
                    <td>
                        @Html.ActionLink("Eliminar", "Eliminar", new { idEvento = ViewBag.id, idGuest = item.GuestID })
                    </td>
                }
              }
              if (String.Compare(item.Guest.Nombre, User.Identity.Name, true) != 0 && !ViewBag.showconfirm)
              {
                    <td>
                     
                    </td>
              }
              
             }
            </tr>
        }
    }


</table>
<p>
    
    @{
        if (ViewBag.showreg)
        {
            @Html.ActionLink("Registrarme", "Register", new { id = ViewBag.id }, (User.Identity.Name == "") ? new { rel = "pop-up", @class = "roundedButton" } : null)

        }
     }
</p>
<!--
<div style="padding-top:20px">
    <a href="" class="roundedButton" onclick="goBack();">Volver</a>
</div>

<script type="text/javascript">
    function goBack(evt) {
        history.go(-1);
        return false;
    }
</script>
-->